package com.vogue.supplymall.common.constant;

/**
 * Created by 崔岳 on 2017/11/29.
 */
public enum ErrorCode {

	/** 未知异常 */
    UnKnow(-1," unknow error: [%s]")
    ,IllegalVisit(1000, "Illegal visit")
    ,ColNNullable(1001,"Table:%s column:%s's value is not nullable ")
    /** 未找到资源 */
    ,NoResource(1002,"%s could not find")
    /** 提交的数据属性不能为空 */
    ,DataAttrNNullable(1003, "Data submit [%s] is not nullable ") 
    /** 数据格式不正确 */
    ,FormatIncorrect(1004, "[%s] format is incorrect")
    /** 数据重复 */
    ,DataRepeat(1005, "[%s] is repeat")
    /** 数据不一致 */
    ,DataInconsistent(1006, "[%s] is inconsistent")
    /** 超时 */
    ,TimeOut(1007, "[%s] is time out")
    /** 操作过于频繁 */
    ,TooFrequent(1008, "%s is too frequent")
    /** 输入的内容长度小于min */
    ,LengthLose(1009,"Input content is too little %s ")
    /** 输入的内容超过max位数 */
    ,LengthOver(1010,"Input content is too long %s ")
    /** 输入的内容的最小值大于最大值 */
    ,LengthError(1011,"Input content Min is greater than the Max %s ")
    /** 查找的数据不存在 */
    ,DataNotFind(1012,"No data find by id or other property")    
    
    //1100~1110 是登录异常占用区间
    /** 访问资源需要登录 */
    ,NeedCredentials(1100, "Need Credentials")
    /** 登录名或密码不正确 */
    ,IncorrectCredentials(1101, "Incorrect Credentials")
    /** 登录失败超过一定次数 */
    ,ExcessiveAttempts(1102, "login fail over five")
    /** 账户已锁定 */
    ,LockedAccount(1103, "account is locked")
    /** 缺少必要权限 */
    ,MissingNecessaryPermissions(1104, "Missing Necessary Permissions %s")
    /** 缺少必要的管理机构 */
    ,MissingLoginOrgan(1105, "Missing Login Organ ")    
    
    
    //1200~1210 注册/登录/平台访问数据业务异常号段
    /** 手机号码重复注册 */
    ,TelRegistRepeat(1200, "[%s] regist is repeat")
    /** 手机号未使用 */
    ,TelIsNotUsed(1201, "[%s] is not used")
    /** 需要一次性登录的操作 */
    ,NeedOnceLogin(1202, "Need Once Login Again")
    /** 操作的数据没有权限 */
    ,NoControlOfData(1203, "No control of data")
    /** 注册号已满无法注册 */
    ,CodeIsFull(1204, "Code Is Null")
    /** 版本太低请先升级 */
    ,NeedUpgrade(1205, "Upgrade First Please")
    //1300~1320 企业、店铺开通业务相关异常
    /** 由于集团信息还没有推送到食尚购中，所以不能进入卖家身份 */
    ,NeedUploadEntInfoToBeSell(1300, "Upload Ent Info First")
    /** 新建并发处理提示：该店铺正在处理中就稍候再试 */
    ,ShopDisposing(1301,"The shop is disposing")
    /** 保存开通申请失败 */
    ,SaveApplyFail(1302, "Save Apply Fail")
    
    //商城商品业务异常专用号段 2000~2599
    ,ParamError(2000, "%s Param Error")
    ,AddWatchFailure(2001, "Add Watch Failure")
    ,AddCollectFailure(2002, "Add Collect Failure")
    // 购物车业务异常专用号段 2600~2999
    ,AddCartFailure(2600, "Add Cart Failure")
    ,UpdateCartFailure(2601, "update Cart Failure")
    ,RemoveCartFailure(2602, "remove Cart Failure")
    ,CartOverMaxCount(2606, "cart over max count")
    ,AddOrderFailure(2607, "Add Order Failure")
    ,AddOrderSuccess(2608, "Add Order Success")
    ,InsufficientInventory(2610, "Insufficient Inventory")
    ,UpdateOrderFailure(2611, "Update Order Failure")
    ,OverProductMaxCount(2614,"Over Product Max Count [%s]")
    ,addCarCheckItem(2615,"car item Units need the same ")
    ,confirmOrderCheckItem(2616,"Submit order check item Units need the same ")
    // 订单合计金额不能超过%s万元
    ,OrderPriceMaxOver(2620, "Order Price Over Max [%s]")
    // 商品信息发生变更，不能购买！
    ,DifferentOrderInfo(2621, "Different Order Info")
    // 起送金额不足
    ,InsufficientSendAmount(2622, "Insufficient Send Amount")
    // 退货订单用message
    ,OverMaxRefundCount(2623, "Over Max Refund Count")
    ,AddExpressFailure(2624, "Add Express Failure")
    ,AddPrepayFailure(2625, "Add Prepay Failure [%s]")
    ,UpdatePrepayFailure(2626, "Update Prepay Failure [%s]")
    ,SearchPrepayFailure(2627, "Search Prepay Failure [%s]")
    // 上传
    ,UploadFailure(2700, "Upload Failure")
    ,RemoveUploadException(2701, "Remove Upload File Failure")
    
    //商品评价
    ,AUCommentFailure(2902,"Add Or Update Comment Failure")
    
    // 管理后台
    ,ParamIsExist(3000, "%s Param Is Exist")
    //系统对接业务异常专用号段 3000~3999
    
    //支付相关异常专用号段 4000~4100
    /**支付失败*/
    ,PayFail(4000, "pay fail %s")
    /**订单超时已经取消*/
    ,OrderIsTimeOver(4001, "%s is Time over")
    /**不支付多单合并付款*/
    ,MergePayDisagree(4002, "Don't allow multiple lists to merge pay")
    /**选择的支付方式有冲突*/
    ,PaymentConflict(4003, "Choose payment with conflicting ways please unify correct way")
    /** 选择的卖家不支持指定的支付方式 */
    ,ShopRefusePayment(4004, "The shop refuse the payment")
    ;
    
    //支付相关异常专用号段 4000~4100
    ;

    private int code;
    private String msg;

    private ErrorCode(int code,String msg){
        this.code=code;
        this.msg=msg;
    }

    public static String getName(int code) {
        for (ErrorCode e : ErrorCode.values()) {
            if (e.code == code) {
                return e.msg;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
